package com.ykg.util;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;


import java.util.concurrent.TimeUnit;

/**
 * TODO
 * 类(接口)：
 * Created on 8:25 2021/6/23.
 *
 * @Author: laobian
 * @Description:
 */
public class CacheUtil {
    private static final Cache<String, String> tokenCache;

    static {
        tokenCache = CacheBuilder.newBuilder()
                .maximumSize(3000L)
                .expireAfterWrite(2, TimeUnit.HOURS)
                .build();
    }

    public static void put(String key, String value) {
        tokenCache.put(key, value);
    }

    public static String get(String key) {
        return tokenCache.getIfPresent(key);
    }
}
